#include <iostream>
#include <vector>

int const maxn = 100007;
long long const mo = 1e9 + 7;
int n;

typedef std::vector<int> adj_edge;
typedef std::vector<adj_edge> graph_type;

graph_type graph;

int main()
{
	int T;
	std::cin >> T;
	for (int ti = 0; ti < T; ti++) {
		std::cout << "Case #" << ti << ": ";
		std::cin >> n;
		graph.clear();
		graph.resize(n);
		for (int i = 0, x, y; i < n; i++) {
			std::cin >> x >> y;
			graph[x].push_back(y);
			graph[y].push_back(x);
		}
		dfs(0);
	}

}
